﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;

public partial class PartyFinderMP : System.Web.UI.MasterPage
{
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!IsPostBack)
        {
            var User = Membership.GetUser();
            if (User != null)
            {
                currentUser.Text = "Logget ind som: " + User.UserName + " - ";
                myAccountLink.Visible = true;

                PartyFinderDBDataContext db = new PartyFinderDBDataContext();
                var notifications = from n in db.Notifications
                                    join p in db.Parties on n.PartyId equals p.PartyId
                                    join u in db.aspnet_Users on p.UserId equals u.UserId
                                    where u.UserName == User.UserName
                                    select new { n.Message, p.Tema, p.Date, p.PartyId };
                if (notifications != null)
                {
                    LWNotifications.DataSource = notifications;
                    LWNotifications.DataBind();
                }

            }
        }
    }
    protected void ButNotification_Click(object sender, EventArgs e)
    {
        Response.Redirect("~/Index/PartySite.aspx");
    }
}
